package com.neusoft.zqygbc.neusoft_wenda.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.baidu.android.pushservice.PushManager;
import com.neusoft.zqygbc.neusoft_wenda.R;

public class SettingActivity extends BaseAvtivity {
    private ImageView setting_return;
    private Button setting_btn;
    private LinearLayout ll_security,ll_currency,ll_about;

    @Override
    void initViews() {
        setLayout(R.layout.activity_setting);
        setting_return = (ImageView) findViewById(R.id.setting_return);
        setting_btn = (Button) findViewById(R.id.setting_btn_exit);
        ll_security = (LinearLayout) findViewById(R.id.ll_security);
        ll_currency = (LinearLayout) findViewById(R.id.ll_currency);
        ll_about = (LinearLayout) findViewById(R.id.ll_about);
    }

    @Override
    void initEvents() {
        setting_return.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
        ll_security.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SettingActivity.this, SecurityActivity.class);
                startActivity(intent);
            }
        });
        ll_currency.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SettingActivity.this, CurrencyActivity.class);
                startActivity(intent);
            }
        });
        ll_about.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(SettingActivity.this, AboutActivity.class);
                startActivity(intent);
            }
        });

        setting_btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                SharedPreferences sp = getSharedPreferences("userinfo", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sp.edit();
                editor.remove("user_id");
                editor.commit();
                //百度推送解除绑定设备
                PushManager.stopWork(getApplicationContext());
                Intent intent = new Intent(SettingActivity.this, MainActivity.class);
                startActivity(intent);

            }
        });

    }

    @Override
    void initData() {

    }
}
